struct ListNode* deleteDuplicates(struct ListNode* head)
{
    struct ListNode *p = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode *ans = p;
 
    p->next = head;
    struct ListNode *q = p->next;
 
    while(p->next && q->next)
    {
        if(q->val == q->next->val)
        { 
            while(q->next && q->val == q->next->val)
            { 
                q = q->next;
            }
            p->next = q->next; 
            q = p->next; 
        }
        else {
            p = p->next;
            q = p->next; 
        }
    }
 
    return ans->next;
}
